package de.uni.muenster.idw2.location.bluetooth.service.fingerprinting.images;

/**
 * Represents a pixel.
 * 
 * @author Eva Peters
 *
 */
public class PixelPosition
{
	/**
	 * The x position in the image.
	 */
	private double x;
	
	/**
	 * The y position in the image.
	 */
	private double y;
	
	/**
	 * Constructor.
	 * 
	 * @param x The x position in the image.
	 * @param y The y position in the image.
	 */
	public PixelPosition(double x, double y)
	{
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Gets the x position in the image.
	 * 
	 * @return
	 */
	public double getX()
	{
		return x;
	}
	
	/**
	 * Gets the y position in the image.
	 * 
	 * @return
	 */
	public double getY()
	{
		return y;
	}
	
	/**
	 * Computes the distance between the given pixel coordinates and this position.
	 * 
	 * @param x_pixel The X pixel coordinate.
	 * @param y_pixel The Y pixel coordinate.
	 * @return The distance.
	 */
	public double computeDistance(int x_pixel, int y_pixel)
	{
		double x_pixel_double = (double) x_pixel;
		double y_pixel_double = (double) y_pixel;
		
		double delta_x = x_pixel_double - x;
		double delta_y = y_pixel_double - y;
		
		double distance = Math.sqrt((delta_x * delta_x) + (delta_y * delta_y));
		return distance;
	}
}
